const moment = require('moment');

//根据起止时间生成随机时间
const randomDate = (startDate, endDate) => {
	let date = new Date(+startDate + Math.random() * (endDate - startDate));
	let hour = (0 + Math.random() * (23 - 0)) | 0;
	let minute = (0 + Math.random() * (59 - 0)) | 0;
	let second = (0 + Math.random() * (59 - 0)) | 0;
	date.setHours(hour);
	date.setMinutes(minute);
	date.setSeconds(second);
	return date;
};

// 生产当月的开始日期
const startDate = new Date('2023-05-06 00:00:00');
// 截止日期
const endDate = new Date('2023-06-10 17:00:00');

function orderTime(startDate, endDate) {
	let tes = moment(randomDate(startDate, endDate)).format(
		'YYYY-MM-DD HH:mm:ss'
	);
	return tes;
}

// console.log(orderTime(startDate, endDate));
module.exports = orderTime;
